/*
 * globals.cpp
 *
 *  Created on: Feb 19, 2012
 *      Author: Michael Ziminsky
 */

matrix::fixed<3, 3> genRotation(scalar rads)
{
	matrix m = {scalar(cos(rads)), scalar(-sin(rads)), 0, scalar(sin(rads)), scalar(cos(rads)), 0, 0, 0, 1};
	m.reshape(3, 3);
	return m;
}

scalar magnitude(const vector3 &v)
{
	return arma::as_scalar(arma::sqrt(arma::sum(arma::square(v))));
}

void normalize(vector3 &v)
{
	v /= magnitude(v);
}

void scale(vector3 &v, scalar s)
{
	normalize(v);
	v *= s;
}